<?php
/**
 * User: fs
 * Date: 2017/9/13
 */
namespace core\lib;
class conf{

    static  public  $conf = array();
    static  public  function  get($name,$file){
        /**
         * 1.配置文件是否存在
         * 2.配置name 是否存在
         * 3.缓存配置
         */
        if(isset(self::$conf[$file])){
            return self::$conf[$file][$name];
        }



        $path = CORE.'/config/'.$file.'.php';
        if(is_file($path)){

            $conf=include $path;
            if(isset($conf[$name])){
                self::$conf[$file]=$conf;
                return $conf[$name];
            }else{
                throw new \Exception("找不到配置名称$name");
            }


        }else{
            throw new \Exception("找不到配置文件$file");
        }

    }

    static  public  function  all($file){
        /**
         * 1.配置文件是否存在
         * 2.配置name 是否存在
         * 3.缓存配置
         */
        if(isset(self::$conf[$file])){
            return self::$conf[$file];
        }



        $path = CORE.'/config/'.$file.'.php';


        if(is_file($path)){

            $conf=include $path;
            self::$conf[$file]=$conf;
            return $conf;



        }else{
            throw new \Exception("找不到配置文件$file");
        }

    }




}